package com.fesine.quartz.chapter4;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.DirectSchedulerFactory;

/**
 * @description: DirectSchedulerFactory学习与使用
 * @author: Fesine
 * @createTime:2016/11/16 16:49
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/16 16:49
 */
public class Listing_4_1 {
    static Log logger = LogFactory.getLog(Listing_4_1.class);

    public static void main(String[] args) {
        Listing_4_1 example = new Listing_4_1();
        example.startScheduler();
    }

    public void startScheduler() {
        //1、通过静态方法获取实例
        DirectSchedulerFactory factory = DirectSchedulerFactory.getInstance();
        try {
            //2、通过createXXX方法初始化
            factory.createVolatileScheduler(10);
            //3、通过getScheduler()方法获取scheduler对象
            Scheduler scheduler = factory.getScheduler();
            logger.info("调度器启动。。。");
            scheduler.start();
        } catch (SchedulerException e) {
            logger.error(e);
        }
    }
}
